from abc import ABCMeta, abstractmethod, abstractproperty


class Node:
    __metaclass__ = ABCMeta

    def __init__(self):
        self.source = []
        self.target = []
        self.dirty = False

    @abstractmethod
    def execute(self):
        return True

    @abstractproperty
    def signature(self):
        return None

    @abstractproperty
    def id(self):
        return None

    def connect(self, tgt):
        connect(self, tgt)
        return tgt

def connect(src, tgt):
    if tgt not in src.target:
        src.target.append(tgt)

    if src not in tgt.source:
        tgt.source.append(src)
